<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>首页</title>
    <meta charset="utf-8">
    <meta content="" name="description">
    <meta content="" name="keywords">
    <meta content="eric.wu" name="author">
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
    <meta content="no-cache" http-equiv="pragma">
    <meta content="0" http-equiv="expires">
    <meta content="telephone=no, address=no" name="format-detection">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
    <link rel="stylesheet" type="text/css" href="/sources/css/main.css">
    <link rel="stylesheet" type="text/css" href="/sources/css/dialog.css">
    <script src="/sources/js/jquery_min.js"></script>
    <script src="/sources/js/main.js"></script>
    <script src="/sources/js/dialog_min.js"></script>
    <script>
       //收藏操作
       //type:提交类型(0取消,1赞),app_id(当前应用id),tid(帖子id),uid(用户id)
       function collectTrends(type, app_id, tid, uid){
            var args = arguments;
            loading(true);
            $.post('{$site_info.route_base}/ajax/collect',{
                "type" : type,
                "app_id"  : app_id,
                "tid"  : tid,
                "uid"  : uid,
                },function(res){
                    loading(false);
                    if("1" == res){
                           var $a = $("#collect_"+tid);
                           var label = $a.find("label")[0];
                           var total = parseInt(label.innerText );
                           $a[0==type?"addClass":"removeClass"]("on");
                           total = (0 == type)?total+1:total-1;
                           label.innerText = total;
                           $a.attr("onclick", 'collectTrends('+[1,0][type]+","+(Array.prototype.slice.call(args, 1).join(','))+');');
                    }
                }
            );
       }
       //点赞操作
       //type:提交类型(0取消,1赞),app_id(当前应用id),tid(帖子id),uid(用户id)
       function praiseTrends(type, app_id, tid, uid){
            var args = arguments;
            loading(true);
            $.post('{$site_info.route_base}/ajax/praise',{
                "type" : type,
                "app_id"  : app_id,
                "tid"  : tid,
                "uid"  : uid,
                },function(res){
                    loading(false);
                    if("1" == res){
                           var $a = $("#praise_"+tid);
                           var label = $a.find("label")[0];
                           var total = parseInt(label.innerText );
                           $a[0==type?"addClass":"removeClass"]("on");
                           total = (0 == type)?total+1:total-1;
                           label.innerText = total;
                           $a.attr("onclick", 'praiseTrends('+[1,0][type]+","+(Array.prototype.slice.call(args, 1).join(','))+');');
                    }
                });
        }
    </script>
</head>
<body onselectstart="return true;" ondragstart="return false;" class="discuss_index">
    <div id="container" class="container">
        <header>
            <div class="header_1">
                <ul class="tbox">
                    <li>
                        <span class="head_img">
                            <img src="{$user_info.user_pic}" onerror="this.src='{$default_info.default_head}';">
                        </span>
                    </li>
                    <li>
                        <h5>{$site_info.title}</h5>
                        <p>
                            <a href="javascript:;" class="label">
                                <span class="icons icons_post">&nbsp;</span>{$site_info.post_num}帖子
                            </a>
                            <a href="javascript:;" class="label">
                                <span class="icons icons_visisted">&nbsp;</span>{$site_info.view_num}访问
                            </a>
                        </p>
                    </li>
                </ul>
            </div>
        </header>
        <div class="body">
            <div id="list_article" class="list_article">
            <!-- 帖子部分start -->
                <foreach name="post_list" item="vo"> 
                <article>
                    <header>
                        <ul class="tbox">
                            <li>
                                <!-- <a href="http://349257.m.weimob.com/snsmobile/othertrendslist?sid=349257&amp;uid=387016&amp;ruid=387016" class="head_img"> -->
                                <a href="javascript:;" class="head_img">
                                    <img src="{$vo.user_info.user_pic}" onerror="this.src='{$default_info.default_head}';">
                                </a>
                            </li>
                            <li>
                                <h5>{$vo.user_info.nick}</h5>
                                <p>{$vo.publish_time|date="Y-m-d H:i:s",###}</p>
                            </li>
                            <li>
                                <a href="{$site_info.route_base}/index/trendsrow/id/{$vo.id}" class="icons icons_edit">&nbsp;</a>
                            </li>
                        </ul>
                    </header>
                    <section>
                        <div>
                            <h5>{$vo.title}</h5>
                            <div>{$vo.intro}</div>
                        </div>
                        <a href="{$site_info.route_base}/index/commentlist/id/{$vo.id}">查看全文</a>
                    </section>
                    <footer>
                        <ul class="box">
                            <li>
                            
                                <a href="javascript:;" class="a_collect <notempty name='vo.is_laud'>on</notempty>" id="collect_{$vo.id}" onclick="collectTrends({$vo.is_laud}, {$site_info.app_id}, {$vo.id}, {$user_info.user_id});">
                                    <span class="icons icons_collect">&nbsp;</span>
                                    <label>{$vo.laud}</label>
                                </a>
                            </li>
                            <li>
                                <a href="{$site_info.route_base}/index/commentlist/id/{$vo.id}" class="a_comment">
                                    <span class="icons icons_comment">&nbsp;</span>
                                    <label>{$vo.comment_count}</label>
                                </a>
                            </li>
                            <li>
                                <a href="javascript:;" class="a_like <notempty name='vo.is_like'>on</notempty>" id="praise_{$vo.id}" onclick="praiseTrends({$vo.is_like}, {$site_info.app_id}, {$vo.id}, {$user_info.user_id});">
                                    <span class="icons icons_like">&nbsp;</span>
                                    <label>{$vo.like}</label>
                                </a>
                            </li>
                        </ul>
                    </footer>
                </article>
                </foreach>
            <!-- 帖子部分start -->
            </div>
       </div>
       <!-- 尾部导航start -->
       <footer>
           <section class="nav_footer">
               <ul class="box">
                   <li>
                       <a href="{$site_info.route_base}/index/index" class="on">
                           <span class="icons_home">&nbsp;</span>
                           <label>首页</label>
                       </a>
                   </li>
                   <li>
                       <a href="{$site_info.route_base}/index/newtrends/user_id/{$user_info.user_id}" class="nav_add">
                           <span class="icons_home_edit">&nbsp;</span>
                       </a>
                   </li>
                   <li>
                       <a href="{$site_info.route_base}/index/messagelist/user_id/{$user_info.user_id}">
                           <span class="icons_my">&nbsp;</span>
                           <label>我的</label>
                       </a>
                   </li>
               </ul>
           </section>
       </footer>
       <!-- 尾部导航end -->
    </div>

<script>
    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        window.shareData = {
            "imgUrl": "http://img.weimob.com/static/8a/c4/b6/image/20141026/20141026210633_84266.jpg",
            "timeLineLink": "http://349257.m.weimob.com/snsmobile/?_tj_twtype=22&_tj_pid=349257&_tt=1&_tj_graphicid=6079949&_tj_title=%E5%B8%AE%E5%B8%AE%E8%B4%AD%EF%BC%8C%E8%BF%98%E6%98%AF%E5%B0%8F%E4%BC%99%E4%BC%B4%E6%8E%A8%E8%8D%90%E7%9A%84%E6%9B%B4%E9%9D%A0%E8%B0%B1&_tj_keywords=%E6%8E%A8%E8%8D%90%E8%B4%AD%E7%89%A9&id=9892&v=c870a293a4a5578b466f623abc1648e2&pid=349257&wechat_id=fromUsername&channel=kw%255E%2523%255E5o6o6I2Q6LSt54mp",
            "sendFriendLink": "http://349257.m.weimob.com/snsmobile/?_tj_twtype=22&_tj_pid=349257&_tt=1&_tj_graphicid=6079949&_tj_title=%E5%B8%AE%E5%B8%AE%E8%B4%AD%EF%BC%8C%E8%BF%98%E6%98%AF%E5%B0%8F%E4%BC%99%E4%BC%B4%E6%8E%A8%E8%8D%90%E7%9A%84%E6%9B%B4%E9%9D%A0%E8%B0%B1&_tj_keywords=%E6%8E%A8%E8%8D%90%E8%B4%AD%E7%89%A9&id=9892&v=c870a293a4a5578b466f623abc1648e2&pid=349257&wechat_id=fromUsername&channel=kw%255E%2523%255E5o6o6I2Q6LSt54mp",
            "weiboLink": "http://349257.m.weimob.com/snsmobile/?_tj_twtype=22&_tj_pid=349257&_tt=1&_tj_graphicid=6079949&_tj_title=%E5%B8%AE%E5%B8%AE%E8%B4%AD%EF%BC%8C%E8%BF%98%E6%98%AF%E5%B0%8F%E4%BC%99%E4%BC%B4%E6%8E%A8%E8%8D%90%E7%9A%84%E6%9B%B4%E9%9D%A0%E8%B0%B1&_tj_keywords=%E6%8E%A8%E8%8D%90%E8%B4%AD%E7%89%A9&id=9892&v=c870a293a4a5578b466f623abc1648e2&pid=349257&wechat_id=fromUsername&channel=kw%255E%2523%255E5o6o6I2Q6LSt54mp",
            "tTitle": "帮帮购，还是小伙伴推荐的更靠谱",
            "tContent": "如果你买东西还搜索，那你就OUT了，朋友推荐的才最靠谱，对不对，赶紧向你的好友求助吧！",
            "fTitle": "帮帮购，还是小伙伴推荐的更靠谱",
            "fContent": "如果你买东西还搜索，那你就OUT了，朋友推荐的才最靠谱，对不对，赶紧向你的好友求助吧！",
            "wContent": "如果你买东西还搜索，那你就OUT了，朋友推荐的才最靠谱，对不对，赶紧向你的好友求助吧！"
        };

        // 发送给好友
        WeixinJSBridge.on('menu:share:appmessage', function (argv) {
            WeixinJSBridge.invoke('sendAppMessage', {
                "img_url": window.shareData.imgUrl,
                "img_width": "640",
                "img_height": "640",
                "link": window.shareData.sendFriendLink,
                "desc": window.shareData.fContent,
                "title": window.shareData.fTitle
            }, function (res) {
                _report('send_msg', '111111');
            })
        });

        // 分享到朋友圈
        WeixinJSBridge.on('menu:share:timeline', function (argv) {
            WeixinJSBridge.invoke('shareTimeline', {
                "img_url": window.shareData.imgUrl,
                "img_width": "640",
                "img_height": "640",
                "link": window.shareData.timeLineLink,
                "desc": window.shareData.tContent,
                "title": window.shareData.tTitle
            }, function (res) {
                _report('timeline', res.err_msg);
            });
        });

        // 分享到微博
        WeixinJSBridge.on('menu:share:weibo', function (argv) {
            WeixinJSBridge.invoke('shareWeibo', {
                "content": window.shareData.wContent,
                "url": window.shareData.weiboLink
            }, function (res) {
                _report('weibo', res.err_msg);
            });
        });
    }, false)
</script>
<script type="text/javascript">  
    $(document).ready(function(){
        var range = 50;                       //距下边界长度/单位px  
        var pageNum = 2;  
        var totalheight = 0;   
        var main = $("#list_article");        //主体元素
        var state = 0;  
        var _srollPos = 0;

        var TPL = '<article {guan}>\
                  <header>\
                      <ul class="tbox">\
                          <li>\
                              <a href="{his_tiezi_href}" class="head_img">\
                                    <img src="{head_img}" onerror="this.src=\'{$site_info.default_head}\';" />\
                              </a>\
                          </li>\
                          <li>\
                                <h5>{nickname}</h5>\
                                <p>{ctime}</p>\
                          </li>\
                          <li>{edit_trend}</li>\
                      </ul>\
                  </header>\
                  <section>\
                      <figure data-count="{image_url_count}张图片" {show_pic}>\
                          <div>{imgs}</div>\
                      </figure>\
                      <div>\
                          <h5>{title}</h5>\
                          <div>{content}</div>\
                          <a href="{comment_href}">查看全文</a>\
                      </div>\
                  </section>\
                  <footer>\
                      <ul class="box">\
                          <li>\
                               <a href="javascript:;"  id="collect_{tid}" class="a_collect {collect_on}" {collect_click} >\
                                   <span class="icons icons_collect" >&nbsp;</span><label>{collect}</label>\
                               </a>\
                          </li>\
                          <li>\
                                 <a href="{comment_href}" class="a_comment">\
                                     <span class="icons icons_comment" >&nbsp;</span><label>{comment}</label>\
                                 </a>\
                          </li>\
                           <li>\
                               <a href="javascript:;" id="praise_{tid}" class="a_like {praise_on}" {praise_click}>\
                                   <span class="icons icons_like"   >&nbsp;</span><label>{praise}</label>\
                               </a>\
                           </li>\
                      </ul>\
                  </footer>\
                  </article>';
                  
        var TPL_imgs = '<img src="{img_url}" data-src="{img_url}" data-gid="g{gi}" onload="preViewImg(this, event);"/>';
        
        $(window).scroll(function(){
            var pageSize = 15;
            var total = 2;
            if( Math.ceil(total/pageSize)<pageNum ){
                  return false;
            }
            var srollPos = $(window).scrollTop();    //滚动条距顶部距离(页面超出窗口的高度)  
            if(srollPos<_srollPos){
                return;
            }else{
                _srollPos = srollPos;
            }
            totalheight = parseFloat($(window).height()) + parseFloat(srollPos);  
            if(!state && (($(document).height()-range) <= totalheight) ) {
                loading(true);
                state = 1;
                $.post('{$site_info.route_base}/ajax/loadlist',{
                    "app_id"  : {$site_info.app_id},
                    "uid" : {$user_info.user_id},
                    "page" : pageNum
                    },function(res){
                        loading(false);
                        if(res) {
                            var data = $.parseJSON(res);
                            //console.log(data);
                            html = iTemplate.makeList(TPL, data.rows, function(k,v){
                            console.log(v);
                            var gi = new Date().getTime();
                            var subObj = {
                                his_tiezi_href:'{$site_info.route_base}/index/othertrendslist',
                                edit_trend:v.uid==v.ruid?'<a href="{$site_info.route_base}/index/trendsrow" class="icons icons_edit">&nbsp;</a>':'',
                                head_img:"2"== v.type?( v.head_img||'{$site_info.default_head}'):(data.shopinfo.image),
                                nickname:"2"== v.type?(v.nickname||'游客'):(data.shopinfo.nickname),
                                guan: "1"==v.type?'data-role="guan"':'',
                                image_url_count: v.image_url[0]? v.image_url.length:0,
                                show_pic:v.image_url[0]?'':'style="display:none;"',
                                imgs: iTemplate.makeList(TPL_imgs, v.image_url, function(kk,vv){
                                    return {
                                         gi: gi 
                                       }
                                }),
                                praise_on:"1" == (parseInt(v.ispraise) && ("0" != {$user_info.user_id}) )?'on':'',
                                collect_on:"1" == (parseInt(v.iscollect) && ("0" != {$user_info.user_id}) )?'on':'',
                                praise_click: "0" == {$user_info.user_id}?'onclick="return false;"': 'onclick="praiseTrends('+v.ispraise+', '+v.sid+', '+v.tid+', '+v.ruid+')"',
                                collect_click: "0" == {$user_info.user_id}?'onclick="return false;"': 'onclick="collectTrends('+v.iscollect+', '+v.sid+', '+v.tid+', '+v.ruid+')"',
                                comment_href: "0" == {$user_info.user_id}?'javascript:;':  '{$site_info.route_base}/index/commentlist/id/'+v.tid,
                                ctime:(function(vctime){
                                    var f_ctime = new Date(vctime);
                                    var arr = [];
                                    arr.push( f_ctime.getFullYear() );
                                    arr.push( "-" + (f_ctime.getMonth()+1 ) );
                                    arr.push( "-" + f_ctime.getDate() );
                                    arr.push( " " + f_ctime.getHours() );
                                    arr.push( ":" + f_ctime.getMinutes() );
                                    arr.push( ":" + f_ctime.getSeconds() );
                                    return arr.join("");
                                })(v.ctime*1000),
                               
                            };
                            return subObj;
                        });
                        main.append($(html) );
                        pageNum ++;
                        state = 0;
                    }else{
                        loading(false);
                        state = 0;
                        alert("没有更多了...","1500");
                    }
                });
            }  
        });  
    }); 


    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        WeixinJSBridge.call('showOptionMenu');
    });
</script> 

</body>
</html>
